namespace DmServer.Unit;

public class Special
{
    public static void Initializie()
    {
        #region 互斥和隐藏
        Mutex mutex = new Mutex(true, "3D6F59E1-9CD5-4e2e-9A16-8DA7C03E6ACD"); // 用一个独特的 GUID

        if (!mutex.WaitOne(TimeSpan.Zero, true))
            return;

        [DllImport("kernel32.dll")]
        static extern IntPtr GetConsoleWindow();
        [DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        const int SW_HIDE = 0;
        const int SW_SHOW = 5;

        var handle = GetConsoleWindow();
        // 隐藏控制台窗口
        ShowWindow(handle, SW_HIDE);
        #endregion
    }
}
